<style lang="scss" scoped>
	.content {

		width: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.nav {
		width: 100%;
		position: fixed;
		top: 0;
		left: 0;
	}

	.top {
		padding: 20rpx 0;
	}

	.search {
		width: 690rpx;
		height: 68rpx;
		background: #f4f5f7;
		border: 2rpx solid #f5f5f5;
		border-radius: 46rpx;
		margin: 0rpx auto;
		padding: 20rpx;

		.ipt {
			flex: 1;
		}
	}

	.footer {
		width: 100%;
		background-color: white;
		position: fixed;
		bottom: 0;
		left: 0;
		border-top: 1px solid #cccccc;
	}

	.box {
		width: 100%;
		padding: 0rpx 20rpx;
		background: #ffffff;

		margin-top: 10rpx;

		.line {
			width: 100%;
			height: 100rpx;
			border-top: 1px solid #eeeeee;

			.ipt {
				width: 500rpx;
				text-align: right;
			}
		}

		.line:first-child {
			border-top: none;
		}



		.line2 {
			width: 100%;
			border-top: 1px solid #eeeeee;
			align-items: flex-start;

			.des {
				width: 500rpx;
				text-align: justify;
			}
		}

		.sbtn {
			width: 184rpx;
			height: 64rpx;
			background: #fffefe;
			border: 2rpx solid #409eff;
			border-radius: 34rpx;
		}

		.imgboxs {
			width: 100%;
			flex-wrap: wrap;

			.imgbox {
				width: 148rpx;
				height: 148rpx;
				border: 2rpx solid #dee2ee;
				border-radius: 10rpx;
				position: relative;
				margin-right: 18rpx;

				.photo {
					width: 100%;
					height: 100%;

				}

				.close {
					position: absolute;
					width: 32rpx;
					height: 32rpx;
					right: -16rpx;
					top: -16rpx;
				}
			}

			.imgbox:nth-child(4n) {

				margin-right: 0rpx;
			}
		}
	}
</style>

<template>
	<view class="content">

		<view class="box">

			<view class="line between-flex f28">
				<view class="gray">工单状态</view>
				<picker mode="selector" :range="dic.ticketState" range-key="name" @change="chooseState">
					<view class="align-flex blue choosearea">
						{{state?state.name:'请选择'}}
						<u-icon name="arrow-right" color="#409EFF" size="28"></u-icon>
					</view>
				</picker>
			</view>
			<!-- <view class="line between-flex f28" @click="personType=0;$navTo(PagesCourseRouterConfig.ChoosePerson+'?type=2')">
			 	<view class="gray">建单人</view>
			 	<view class="blue">{{createUser?createUser.name:'请选择'}}
			 		<u-icon name='arrow-right'></u-icon>
			 	</view>
			 </view>
			 <view class="line between-flex f28" @click="personType=1;$navTo(PagesCourseRouterConfig.ChoosePerson+'?type=2')">
			 	<view class="gray">处理人</view>
			 	<view class="blue">{{makeUser?makeUser.name:'请选择'}}
			 		<u-icon name='arrow-right'></u-icon>
			 	</view>
			 </view> -->
			<view class="line between-flex f28" @click="$navTo(PagesCourseRouterConfig.ChooseDept)">
				<view class="gray">报修科室</view>
				<view class="blue">{{dept?dept.name:'请选择'}}
					<u-icon name='arrow-right'></u-icon>
				</view>
			</view>
			<!-- <view class="line between-flex f28"  @click="personType=2;$navTo(PagesCourseRouterConfig.ChoosePerson+'?type=2')">
				<view class="gray">报修人</view>
				<view class="blue">{{createUser?createUser.name:'请选择'}} <u-icon name='arrow-right'></u-icon>
				</view>
			</view> -->
			<view class="line between-flex f28" @click="showStarttime=true">
				<view class="gray">开始时间</view>
				<view class="blue">{{startTime?startTime:'请选择'}}
					<u-icon name='arrow-right'></u-icon>
				</view>
			</view>
			<view class="line between-flex f28" @click="showEndtime=true">
				<view class="gray">结束时间</view>
				<view class="blue">{{endTime?endTime:'请选择'}}
					<u-icon name='arrow-right'></u-icon>
				</view>
			</view>
		</view>

		<view class="space"></view>
		<view class="footer   paddingBottom">
			<BttonGroup @leftClick="clear" @rightClick="submit"></BttonGroup>
		</view>
		<u-picker v-model="showStarttime" mode="time" :params="params" @confirm="confirm($event,1)"></u-picker>
		<u-picker v-model="showEndtime" mode="time" :params="params" @confirm="confirm($event,2)"></u-picker>
	</view>
</template>

<script>
	import BttonGroup from '@/components/buttonGroup/groupTwo.vue'
	import PagesCourseRouterConfig from '@/pagesCourse/routerConfig.js'
	import { Storage_IsFactory, Storage_UserInfo } from '@/common/index.js'
	export default {
		components: {
			BttonGroup
		},
		data() {
			return {
				PagesCourseRouterConfig,
				dic: uni.getStorageSync('dic'),
				head: this.$head,
				state: null, //工单状态
				personType: 0, //0建单人1处理人
				createUser: null,
				makeUser: null,
				dept: null,
				startTime: '',
				endTime: '',
				showStarttime: false,
				showEndtime: false,
				params: {
					year: true,
					month: true,
					day: true,
					hour: false,
					minute: false,
					second: false
				},

			}
		},

		computed: {

		},
		onLoad() {
			uni.$on('choosePerson', (data) => {
				if (this.personType == 0) {
					this.createUser = data
				} else {
					this.makeUser = data
				}
			})
			uni.$on('clear', () => {
				this.clear()
			})
		},
		beforeDestroy() {
			uni.$off('choosePerson')
			uni.$off('clear')
		},
		methods: {
			submit() {
				let createUser = ''
				let makeUser = Storage_UserInfo().id

				var obj = {
					currState: this.state ? this.state.value : '',
					createUser,
					makeUser,
					deptId: this.dept ? this.dept.id : '',
					faultStartTime: this.startTime,
					faultEndTime: this.endTime
				}
				let queryParams = JSON.stringify(obj)
				wx.redirectTo({
					url: `/pages/order/search?query=${queryParams}`
				})
			},
			clear() {
				this.state = null
				this.createUser = null
				this.makeUser = null
				this.dept = null
				this.startTime = ''
				this.endTime = ''
			},
			confirm(e, index) {
				if (index == 1) {
					this.startTime = e.year + '-' + e.month + '-' + e.day
				} else {
					this.endTime = e.year + '-' + e.month + '-' + e.day
				}
			},
			chooseState(e) {
				this.state = this.dic.ticketState[e.detail.value]
			}

		}
	}
</script>
